-
Notifications
You must be signed in to change notification settings - Fork 633
[MNY-327] SDK: Display error returned from API in login with phone number UI #8548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
WalkthroughAccountStatus changed from a string union to a discriminated union carrying an optional error message. OTP send error handling now parses response bodies to extract an API Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/thirdweb/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,jsx,ts,tsx,json}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🔇 Additional comments (5)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Fixes #8514 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts (1)
53-68: HardensendOtperror parsing + fixPromise<void>vsresponse.json()mismatch (can throw on 204/empty).
Right nowsendOtpadvertisesPromise<void>but still parses JSON on success (Line 67); if the endpoint ever returns an empty body / 204, this will throw and break OTP send.Suggested tightening (also keeps the new “API message” behavior, but avoids showing raw HTML, and adds status context):
export const sendOtp = async (args: PreAuthArgsType): Promise<void> => { @@ if (!response.ok) { - const raw = await response.text(); - let message: string | undefined; + const raw = await response.text(); + let message: string | undefined; try { const parsed = JSON.parse(raw); if (parsed && typeof parsed.message === "string") { message = parsed.message; } } catch { // ignore parse errors } - throw new Error(message || "Failed to send verification code"); + throw new Error( + message || + `Failed to send verification code (HTTP ${response.status})`, + ); } - return await response.json(); + // Endpoint success payload should not be required by callers. + // If the API returns JSON, callers can be updated to return it explicitly later. + return; };If callers do need the payload, I’d rather change the signature to
Promise<YourResponseType>than keepPromise<void>+ parsing.packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx (1)
328-373: Resend button should be semantically disabled (a11y), not just “no onClick + opacity”.
Right now it stays focusable and looks disabled but isn’t announced as disabled. Preferdisabled(if underlying element is a<button>) and/oraria-disabled.{accountStatus.type !== "sending" && ( <LinkButton - onClick={countdown === 0 ? sendEmailOrSms : undefined} + onClick={countdown === 0 ? sendEmailOrSms : undefined} + disabled={countdown > 0} + aria-disabled={countdown > 0} style={{ cursor: countdown > 0 ? "default" : "pointer", opacity: countdown > 0 ? 0.5 : 1, }} className="tw-resend-button" type="button" >If
StyledButtondoesn’t forwarddisabledto a real<button>, then at least addaria-disabled+ remove from tab order when disabled (tabIndex={countdown > 0 ? -1 : 0}).
🧹 Nitpick comments (1)
packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx (1)
32-36: MakeAccountStatuserror message optional (cleaner union) + consider resetting countdown on send start.
{ type: "error"; message: string | undefined }forcesmessageto exist even when absent;message?: stringis simpler and matches the intent.type AccountStatus = | { type: "sending" } | { type: "sent" } - | { type: "error"; message: string | undefined }; + | { type: "error"; message?: string }; @@ const sendEmailOrSms = useCallback(async () => { setOtpInput(""); setVerifyStatus("idle"); setAccountStatus({ type: "sending" }); + // Optional: prevent stale countdown if a prior send was in progress + // setCountdown(0); @@ setAccountStatus({ type: "error", - message: e instanceof Error ? e.message : undefined, + message: e instanceof Error ? e.message : undefined, }); } }, [props.client, userInfo, ecosystem]);Also applies to: 58-60, 71-106
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx(7 hunks)packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes in TypeScript
Avoidanyandunknownin TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.) in TypeScript
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity and testability
Re-use shared types from @/types or local types.ts barrel exports
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics whenever possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic in TypeScript files; avoid restating TypeScript types and signatures in prose
Files:
packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.tspackages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx
packages/thirdweb/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g.const { jsPDF } = await import("jspdf");)Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)
Files:
packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.tspackages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Biome governs formatting and linting; its rules live in biome.json. Run
pnpm fix&pnpm lintbefore committing, ensure there are no linting errors
Files:
packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.tspackages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Lazy-import optional features; avoid top-level side-effects
Files:
packages/thirdweb/src/wallets/in-app/web/lib/auth/otp.tspackages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx
🧬 Code graph analysis (1)
packages/thirdweb/src/react/web/wallets/shared/OTPLoginUI.tsx (2)
packages/thirdweb/src/react/web/ui/components/basic.tsx (1)
Container(80-193)packages/thirdweb/src/react/web/ui/components/text.tsx (1)
Text(18-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Lint Packages
- GitHub Check: Build Packages
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: Analyze (javascript)
size-limit report 📦
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8548 +/- ##
==========================================
- Coverage 54.67% 54.64% -0.03%
==========================================
Files 921 921
Lines 61163 61181 +18
Branches 4153 4151 -2
==========================================
- Hits 33439 33434 -5
- Misses 27622 27645 +23
Partials 102 102
🚀 New features to boost your workflow:
|
Merge activity
|
…mber UI (#8548) <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on improving error handling and state management in the OTP authentication process. It enhances the way error messages are displayed and modifies the structure of `AccountStatus` to accommodate additional information. ### Detailed summary - In `otp.ts`, enhanced error handling by parsing the response for a detailed message. - Updated `AccountStatus` type in `OTPLoginUI.tsx` to an object structure, allowing for an error message. - Modified state management for `accountStatus` to use the new object structure. - Adjusted UI rendering logic to handle the new `AccountStatus` format. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced error message handling in OTP verification to display detailed server error messages to users instead of generic messages. * Improved error status display in OTP login interface. * **Style** * Updated OTP login UI layout and spacing for better status presentation. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
8b58713 to
1169752
Compare

PR-Codex overview
This PR enhances error handling and state management in the OTP authentication process. It improves the way error messages are displayed and refines the
AccountStatustype to better represent different states during the OTP login process.Detailed summary
otp.tsby parsing the response and providing a specific error message.AccountStatustype inOTPLoginUI.tsxto use a discriminated union withtypeand optionalmessage.OTPLoginUIto reflect the newAccountStatusstructure.AccountStatus.Summary by CodeRabbit
Bug Fixes
Style
✏️ Tip: You can customize this high-level summary in your review settings.